﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Nirvana
{
    [RequireComponent(typeof(Camera))]
    [AddComponentMenu("Nirvana/Render/Culling Camera")]
    public sealed class CullingCamera : MonoBehaviour
    {
        private Camera _camera;
        private Plane[] _planes = new Plane[6];
        private void Awake()
        {
            this._camera = base.GetComponent<Camera>();
        }
        //当此摄像机剔除了某个渲染场景时候触发此消息。仅在剔除起作用之前被调用。
        private void OnPreCull()
        {
            GeometryUtilityHelper.ExtractPlanes(this._planes, this._camera);
            Singleton<CullingManager>.Instance.CullingRenderers(this._planes);
        }
        //当此摄像机范围内所有渲染都完成时候触发此消息。
        private void OnPostRender()
        {
            Singleton<CullingManager>.Instance.RestoreRenderers();
        }
        /// <summary>
        /// 当此摄像机开始渲染某个场景时候触发此消息。
        /// </summary>
        private void OnPreRender()
        {

        }
    }
}

